<?php
	//
	// Retourne le chemin relatif de $depart à $arrivee
	//
	function get_relative_path($depart, $arrivee){
		//
		$firstPathParts = explode(DIRECTORY_SEPARATOR, $depart);
		$secondPathParts = explode(DIRECTORY_SEPARATOR, $arrivee);
		//
		$sameCounter = 0;
		for($i = 0; $i < min( count($firstPathParts), count($secondPathParts) ); $i++) {
			if( strtolower($firstPathParts[$i]) !== strtolower($secondPathParts[$i]) ) {
				break;
			}
			$sameCounter++;
		}
		if( $sameCounter == 0 ) {
			return $arrivee;
		}
		//
		$newPath = '';
		for($i = $sameCounter; $i < count($firstPathParts); $i++) {
			if( $i > $sameCounter ) {
				$newPath .= DIRECTORY_SEPARATOR;
			}
			$newPath .= "..";
		}
		if( count($newPath) == 0 ) {
			$newPath = ".";
		}
		for($i = $sameCounter; $i < count($secondPathParts); $i++) {
			$newPath .= DIRECTORY_SEPARATOR;
			$newPath .= $secondPathParts[$i];
		}
		//
		return $newPath;
	}
	//
?>